package cn.com.open.itembank.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * 个体（即试卷结构）.
 */
public class GenoType {
    public GenoType() {
        this.selectedQuestionSerialNums = new ArrayList<>();
        this.mutexQuestionGroupIDs = new ArrayList<>();
        this.paperChapterIDs = new ArrayList<>();
        this.paperPartDtos = new ArrayList<>();
        this.fitness = 0;
        this.rfitness = 0;
        this.cfitness = 0;
    }

    /**
     * 互斥题列表（QuestionID）集合.
     */
    private List<String> mutexQuestionGroupIDs;
    /**
     * 模块（部分）.
     */
    private List<PaperPartDto> paperPartDtos;
    /**
     * 试卷中已经选用过的试题编号列表(不包括必考题).
     */
    private List<Integer> selectedQuestionSerialNums;
    /**
     * 章取值.
     */
    private List<String> paperChapterIDs;
    /**
     * 适应度.
     */
    private double fitness;
    /**
     * 相关适应度.
     */
    private double rfitness;
    /**
     * 整体适应度.
     */
    private double cfitness;

    /**
     * Gets repulsive question group i ds.
     *
     * @return the repulsive question group i ds
     */
    public List<String> getMutexQuestionGroupIDs() {
        if (mutexQuestionGroupIDs == null) {
            mutexQuestionGroupIDs = new ArrayList<>();
        }
        return mutexQuestionGroupIDs;
    }

    /**
     * Gets paper parts.
     *
     * @return the paper parts
     */
    public List<PaperPartDto> getPaperPartDtos() {
        if (paperPartDtos == null) {
            paperPartDtos = new ArrayList<>();
        }
        return paperPartDtos;
    }

    /**
     * Gets selected question serial nums.
     *
     * @return the selected question serial nums
     */
    public List<Integer> getSelectedQuestionSerialNums() {
        if (selectedQuestionSerialNums == null) {
            selectedQuestionSerialNums = new ArrayList<>();
        }
        return selectedQuestionSerialNums;
    }

    /**
     * Gets paper chapter i ds.
     *
     * @return the paper chapter i ds
     */
    public List<String> getPaperChapterIDs() {
        if (paperChapterIDs == null) {
            paperChapterIDs = new ArrayList<>();
        }
        return paperChapterIDs;
    }

    /**
     * Gets fitness.
     *
     * @return the fitness
     */
    public double getFitness() {
        return fitness;
    }

    /**
     * Sets fitness.
     *
     * @param fitness the fitness
     */
    public void setFitness(double fitness) {
        this.fitness = fitness;
    }

    /**
     * Gets rfitness.
     *
     * @return the rfitness
     */
    public double getRfitness() {
        return rfitness;
    }

    /**
     * Sets rfitness.
     *
     * @param rfitness the rfitness
     */
    public void setRfitness(double rfitness) {
        this.rfitness = rfitness;
    }

    /**
     * Gets cfitness.
     *
     * @return the cfitness
     */
    public double getCfitness() {
        return cfitness;
    }

    /**
     * Sets cfitness.
     *
     * @param cfitness the cfitness
     */
    public void setCfitness(double cfitness) {
        this.cfitness = cfitness;
    }

    /**
     * copy geno type.
     *
     * @return the geno type
     */
    public GenoType copy() {
        GenoType copy = new GenoType();
        copy.fitness = fitness;
        copy.cfitness = cfitness;
        copy.rfitness = rfitness;

        for (Integer num : selectedQuestionSerialNums) {
            copy.selectedQuestionSerialNums.add(num);
        }
        for (String id : mutexQuestionGroupIDs) {
            copy.mutexQuestionGroupIDs.add(id);
        }

        for (PaperPartDto p : this.paperPartDtos) {
            copy.paperPartDtos.add(p.copy());
        }

        return copy;
    }
}
